package com.yfp.group.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.group.enums.PayTypeEnums;
import com.yfp.group.service.PayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 
 * @version 1.0
 * @date 2024-08-10 9:53
 */
@RestController
@RequestMapping("/pay")
@Tag(name = "微信支付回调")
public class PayController extends BaseController {

    @Resource
    private PayService payService;

    @GetMapping("/type")
    @Operation(summary = "支付类型", description = "支付创建订单使用")
    public R<PayTypeEnums[]> PayTypeEnums() {
        PayTypeEnums[] values = PayTypeEnums.values();
        return R.ok(values);
    }

    @PostMapping("/weixin/notify/create")
    @Operation(summary = "微信支付回调通知处理", description = "支付创建订单使用")
    public String parseOrderNotifyResult(@RequestBody String xmlData) {
        return payService.parseOrderNotifyResult(xmlData);
    }

    @PostMapping("/weixin/native/notify")
    @Operation(summary = "微信二维码支付回调通知处理", description = "支付创建订单使用")
    public String parseOrderNativeNotifyResult(@RequestBody String xmlData) {
        return payService.parseOrderNativeNotifyResult(xmlData);
    }

    @PostMapping("/weixin/notify/refund")
    @Operation(summary = "退款回调通知处理", description = "支付创建订单使用")
    public String parseRefundNotifyResult(@RequestBody String xmlData) {
        return payService.parseRefundNotifyResult(xmlData);
    }
}
